#include "PlayerMenu.h"

#include <boost/bind.hpp>
#include "../../../../domain/models/CardSet.h"

using namespace Views::Helpers::Server;
using namespace Views::Helpers::Server::Gameplay;
using namespace Utils;

PlayerMenu::PlayerMenu(Players::Player* player)
	:player(player)
{
	Shape = sf::Shape::Rectangle(0, 0, 200., 600., sf::Color(123, 22, 92));

	addPlayerName();
	addPlayersCards();
}

void PlayerMenu::addPlayerName()
{
	GUI::Label* PlayerName = new GUI::Label(player->getName());
	PlayerName->SetAlign(GUI::Label::CENTER);
	PlayerName->SetTextWidth(this->GetWidth());
	PlayerName->Move(0, 10);

	this->addChild(PlayerName);
}

void PlayerMenu::addPlayersCards()
{
	GUI::Label* Label = new GUI::Label(L"Twoje karty");
	Label->SetAlign(GUI::Label::CENTER);
	Label->SetTextWidth(this->GetWidth());
	Label->Move(0, 100);
	this->addChild(Label);

	int pos = 140;
	for (Cards::CardSet::Iterator i = player->getCards().begin(); i != player->getCards().end(); i++)
	{
		Views::Helpers::Graphic::CardControl* Card = Views::Helpers::Graphic::CardControlFactory::create(*i);
		Card->Move(5, pos);
		pos += Card->GetHeight() + 5;
		addChild(Card);
	}
}

